package com.hlf.modules.merchant.goods.controller;

import com.hlf.common.utils.PageUtils;
import com.hlf.common.utils.ReturnResult;
import com.hlf.modules.merchant.goods.entity.Goods;
import com.hlf.modules.merchant.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


/**
 * 商品列表
 */
@RestController
@RequestMapping("goods/")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//	@RequiresPermissions("store:view")
    public ReturnResult list(@RequestParam Map<String, Object> params) {
        PageUtils pageUtil = goodsService.queryListForPage(params);
        return ReturnResult.ok().put("page", pageUtil);
    }

    /**
     * 通过id查找商品信息
     */
    @RequestMapping("/info/{goodsId}")
    public ReturnResult config(@PathVariable("goodsId") String goodsId) {
        Goods goods = goodsService.queryObject(Long.parseLong(goodsId));
        return ReturnResult.ok().put("goods", goods);
    }


}
